﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace GUI_Web
{
    public partial class Quadro : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void calendarchange(object sender, EventArgs e)
        {
            DateTime d = quadroCalendar.SelectedDate;
            DayOfWeek dow = d.DayOfWeek;


            string labeltext =
                "<table width=\"840\" border=\"1\" style=\"border-collapse:collapse;\">" +
                    "<tr style=\"height: 30px; text-align: center;\">" +
                        "<td style=\"width:40px; background: #bbb;\">" +
                        "</td>" +
                        "<td style=\"width:160px; background: #bbb;\">" + this.translateDoW(dow.ToString()) + 
                            " ( " + d.Day + "/" + d.Month + " )" +
                        "</td>" +
                        "<td style=\"width:160px; background: #bbb;\">" + this.translateDoW(d.AddDays(1).DayOfWeek.ToString()) +
                            " ( " + d.AddDays(1).Day + "/" + d.AddDays(1).Month + " )" +
                        "</td>" +
                        "<td style=\"width:160px; background: #bbb;\">" + this.translateDoW(d.AddDays(2).DayOfWeek.ToString()) +
                            " ( " + d.AddDays(2).Day + "/" + d.AddDays(2).Month + " )" +
                        "</td>" +
                        "<td style=\"width:160px; background: #bbb;\">" + this.translateDoW(d.AddDays(3).DayOfWeek.ToString()) +
                            " ( " + d.AddDays(3).Day + "/" + d.AddDays(3).Month + " )" +
                        "</td>" +
                        "<td style=\"width:160px; background: #bbb;\">" + this.translateDoW(d.AddDays(4).DayOfWeek.ToString()) +
                            " ( " + d.AddDays(4).Day + "/" + d.AddDays(4).Month + " )" +
                        "</td>" +
                    "</tr>";

            DateTime time = new DateTime(1960, 2, 2, 7, 0, 0);
            for (int i = 0; i < 34; i++)
            {
                labeltext += "<tr style=\"height: 30px;\">" +
                                "<td style=\"background: #bbb;\">" + time.ToShortTimeString() +
                                "</td>" +
                                "<td>" + 
                                "</td>" +
                                "<td>" + 
                                "</td>" +
                                "<td>" + 
                                "</td>" +
                                "<td>" + 
                                "</td>" +
                                "<td>" + 
                                "</td>" +
                            "</tr>";
                time = time.AddMinutes(30);
            }

            labeltext += "</table>";

            lblQuadro.Text = labeltext;
        }

        private string translateDoW(string engDoW)
        {
            switch (engDoW)
            {
                case "Monday":
                    return "Segunda-feira";
                case "Tuesday":
                    return "Terça-feira";
                case "Wednesday":
                    return "Quarta-feira";
                case "Thursday":
                    return "Quinta-feira";
                case "Friday":
                    return "Sexta-feira";
                case "Saturday":
                    return "Sábado";
                case "Sunday":
                    return "Domingo";
            }
            return engDoW;
        }
    }
}